<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var arr = [12, 34, 2, 4, 34, 67, 812, 232, 34, 2, 3]
    console.log(...arr);
    //取最大值
    //方法1：可以先排序，然后再取最大值

    var arr = arr.sort(function (a, b) {
        return (a - b)
    })
    console.log(arr);
    //方法2：利用内置的Math函数
    var num = Math.max(...arr)
    console.log(num);


    //求和
    var brr = [12, 34, 2, 4, 34, 67, 812, 232, 34, 2, 3]
    var sum = 0
    for (var i = 0; i < brr.length; i++) {
        sum += brr[i]
    }
    console.log(sum);

    //方法二
   var res= brr.reduce((prev,cur)=>{
        return prev+cur
    })
    console.log(res);
</script>

</html>